﻿@namespace MudBlazor.UnitTests.TestComponents

<MudTable T="string" Items="items" OnRowMouseEnter="@(args => OnRowMouseEnter(args))" OnRowMouseLeave="@(args => OnRowMouseLeave(args))">
    <RowTemplate>
        <MudTd>@context</MudTd>
    </RowTemplate>
</MudTable>

<p>
    Current: '@(currentlyHoveredItem)', last: '@(lastHoveredItem)'
</p>

@code {
    public static string __description__ = @"
        OnRowMouseEnter should be called whenever a row (<tr>) starts being hovered (onpointerenter).
        OnRowMouseLeave should be called whenever a row (<tr>) stops being hovered (onpointerleave).
        The paragraph (<p>) should be refreshed with the current and last hovered element.
        ";

    string[] items = new string[] { "A", "B" };

    string currentlyHoveredItem = string.Empty;
    string lastHoveredItem = string.Empty;

    private void OnRowMouseEnter(TableRowHoverEventArgs<string> args)
    {
        currentlyHoveredItem = args.Item;
    }

    private void OnRowMouseLeave(TableRowHoverEventArgs<string> args)
    {
        currentlyHoveredItem = string.Empty;
        lastHoveredItem = args.Item;
    }
}
